Skip to content

[6.x] Implement AssetTransformers - #18869

Draft
riasvdv wants to merge 13 commits into
6.xfrom
feature/transforms
Draft

[6.x] Implement AssetTransformers#18869
riasvdv wants to merge 13 commits into
6.xfrom
feature/transforms

Conversation

@riasvdv

@riasvdv riasvdv commented May 14, 2026

Copy link
Copy Markdown
Contributor

Description

Refactors asset transforms around a generic transformer registry. Filesystems can now define a default transformer, individual transform calls and named image transforms can override it, and plugins can register custom asset transformers with their own cache keys, settings UI, and GraphQL arguments.

Craft’s built-in transformer is registered as craft, supports private/no-URL transform filesystems via signed action URLs, and runtime transform resolution now goes through the new AssetTransforms service/facade.

Legacy image transformer compatibility remains in the Yii adapter layer.

See docs/asset-transformers.md for documentation on usage

1. the `transformer` value in the transform array
2. the transformer selected by the named image transform
3. the asset filesystem's default transformer
4. Craft's built-in `craft` transformer

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GeneralConfig's default transformer, not just 'craft' (so it can be overridden globally)

'height' => 800,
'blur' => 12,
]);
```

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$asset->transform('cloudflare')->getUrl($transformData)

asset.transform('cloudflare')->getUrl([
    'width' => 1200,
    'height' => 800,
    'blur' => 12,
]);
class AssetTransform
{
  use ForwardsCalls;

  public function __construct(
    private Asset $asset,
    private AssetTransformer $transformer,  
  ) {
    
  }

  public function getUrl(TransformData $transformData): string
  {
    return $this->transformer->getAssetUrl($this->asset, $transformData);
  }

  public function __call($method, $parameters): mixed
  {
    $this->forwardCallTo($this->query, $method, $parameters);

    return $this;
  }
}


## Registering a Transformer

Register transformers by listening for `AssetTransformersResolving`.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Laravel Manager driver system instead of event?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant